import Vue from 'vue'
import App from './App'

// vuex
import store from './store'

import uView from '@/uni_modules/uview-ui'

// 引入uView提供的对vuex的简写法文件
Vue.prototype.$store = store


Vue.config.productionTip = false
App.mpType = 'app'
Vue.use(uView)
require('./common/props')


Vue.filter('substring', function(input, length) {
	if (input) {
		if (input.length <= length) {
			return input
		} else {
			return input.substring(0, length) + '...'
		}
	} else {
		return "";
	}
})

Vue.filter('formatDate', function(value) {
	const date = new Date(value);
	const year = date.getFullYear();
	const month = date.getMonth() + 1;
	const day = date.getDate();
	return `${year}/${month < 10 ? '0' + month : month}/${day < 10 ? '0' + day : day}`;
})

Vue.filter('formatCurrency', function(value) {
	const formattedAmount = value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
	return formattedAmount;
})

import util from '@/util/util.js'
Vue.prototype.$util = util


import mixin from './common/mixin'
Vue.mixin(mixin)

// 全局mixins，用于实现setData等功能';
import Mixin from './polyfill/mixins';
Vue.mixin(Mixin);


let vuexStore = require('@/store/$u.mixin.js');
Vue.mixin(vuexStore);

const app = new Vue({
	store,
	...App
})

// 引入请求封装
require('./util/request/index')(app)

app.$mount()
